#!/bin/sh
#****************************************************************#
# ScriptName: my1
#!/bin/sh
#****************************************************************#
# ScriptName: my1
#             switch to mysql instance 1 environment
# Author: pickup.li
# Create Date: 2013-09-11
# Modify Author:
# Modify Date: 2013-09-11
# Function:
#***************************************************************#
#set -x

#### variable should change every instance
INSTANCE_NO=1
INSTANCE_PORT=3306

#### variable should not change every instance
export BASE_DIR=/usr/local/mysql
export DATA_DIR=/home/mysql/data/mysqldata$INSTANCE_NO/
export MYSQL_CONF=/home/mysql/conf/my$INSTANCE_NO.cnf
export PS1='\n\e[1;37m[\e[m\e[1;31m\u\e[m\e[1;31m@\e[m\e[1;31m\h\e[m \e[1;31mMySQL_$INSTANCE_NO\e[m \e[4m`pwd`\e[m\e[1;37m]\e[m\e[1;36m\e[m\n\$'
startmysql()
{
	cd $BASE_DIR/
	$BASE_DIR/bin/mysqld_safe --defaults-file=$MYSQL_CONF &
	cd -
}
alias stopmysql="$BASE_DIR/bin/mysqladmin -uroot --password='****' -h127.0.0.1 -P$INSTANCE_PORT shutdown"
alias my="$BASE_DIR/bin/mysql --defaults-file=$MYSQL_CONF -uroot --password='****' -h127.0.0.1 -P$INSTANCE_PORT test --prompt='[\\v $(whoami)@$(hostname) $(pwd) \\u@\\h:\\d \\R:\\m:\\s]\\n>'"

export PATH=$BASE_DIR/bin/:$PATH
export LD_LIBRARY_PATH=$BASE_DIR/lib/:$BASE_DIR/lib/mysql
export PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}"; echo -ne "\007"'
alias cdd="cd $DATA_DIR"
alias cdb="cd $BASE_DIR"
alias cdm="cd /home/mysql/"
alias vi="vim"
alias vie="vim $DATA_DIR/log/error.log"
alias cate="cat $DATA_DIR/log/error.log"
alias psm="ps -eo pid,cgroup,cmd|grep $BASE_DIR/bin/mysqld |grep -i mysql$INSTANCE_NO.cnf |grep -v grep"
alias ll='ls -l -G'
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
